package com.wang.designpattern.strategy;

import com.wang.designpattern.strategy.behavior.FlyBehavior;
import com.wang.designpattern.strategy.behavior.QuackBehavior;

public abstract class Duck {

    // 属性，策略接口
    FlyBehavior flyBehavior;

    QuackBehavior quackBehavior;

    public Duck() {}

    // 显示鸭子信息
    public abstract void display();

    public void fly() {
        if (null != flyBehavior) {
            flyBehavior.fly();
        }
    }

    public void quack() {
        if (null != quackBehavior) {
            quackBehavior.quack();
        }
    }
}
